import asyncio
import websockets
import time
from threading import Thread

ws = None
val = 0

async def hello():
    global ws, val
    val = 10
    ws = await websockets.connect("ws://localhost:8765/unity")
    await asyncio.Future()

async def sendMsg():
    print(val)
    while (ws == None):
        pass
    await ws.send("[1]")

# time.sleep(5)
thread = Thread(target=lambda: asyncio.run(hello()) )
thread.start()

thread2 = Thread(target=lambda: asyncio.run(sendMsg()) )
thread2.start()

